<!-- 金料库 -->
<template>
	<view class="goldWarehouse" :style="{backgroundImage:`url(${HTTP_REQUEST_URL}/zggyuniapp/goldVaultBg.png)`}">
		<view class="nav_box" :style="{'padding-top': statusBar + 'px'}">
			<view class="nav_title flex_s" :style="{'height':navBar+'px'}">
				<view class="image_box">
					<image :src="HTTP_REQUEST_URL+'/zggyuniapp/logoBg.png'" mode="aspectFill"></image>
				</view>
			</view>
		</view>
		<!-- <view class="tab_box flex_se">
			<view class="tab_item" :class="tagIndex==index?`active active${index}`:''"
				v-for="(item,index) in tagList" :key="index" @click="tagIndex=index">
				{{item}}
			</view>
		</view> -->
		<view class="main_box">
			<view class="title_box">
				<image src="@/static/statacImg/gold_ku1.png" mode="aspectFill"></image>
			</view>
			<view class="content_box">
				<view class="gold_price">
					实时金价：{{goldPrice}}元/g
				</view>
				<view class="main_class">
					<view class="my_wight_class">
						我的黄金
					</view>
					<view class="info_box">
						<view class="info_title">
							黄金
						</view>
						<view class="unitPrice">
							{{goldInfo.gold_stock || 0}}g
						</view>
						<view class="estimate">
							预计价值：{{(goldInfo.gold_stock * goldInfo.recycle_price).toFixed(2) }}元
						</view>
						<view class="btn_box" @click="$util.JumpPath('/pages/new_gold/goldWarehouse/sell')">
							立即卖出
						</view>
					</view>

				</view>

				<!-- <view class="inoutBox flex_sb">
					<view class="listItem" v-for="(sa,idx) in inOutList" :key="idx" @click="change(idx)">
						<image :src="sa.icon" mode="widthFix"></image>
						{{sa.name}}
					</view>
				</view> -->

			</view>
		</view>

		<pageFooter></pageFooter>
	</view>
</template>

<script>
	import {
		homepage_gold,
	} from '@/api/new_api.js';
	import {
		HTTP_REQUEST_URL
	} from '@/config/app.js'
	import pageFooter from '@/components/pageFooter/index.vue'
	import {
		getMytock
	} from '@/api/new_store.js'
	export default {
		components: {
			pageFooter
		},
		data() {
			return {
				HTTP_REQUEST_URL,
				statusBar: this.statusBar || 0,
				navBar: this.navBar || 0,
				isSticky: false, // 控制模块是否吸顶
				tagList: ['黄金', '铂金', '白银', '钯金'],
				tagIndex: 0,

				inOutList: [{
						name: '卖出',
						icon: require('@/static/imgs/list2.png')
					},
					{
						name: '提货',
						icon: require('@/static/imgs/list0.png')
					},
					{
						name: '兑换',
						icon: require('@/static/imgs/list1.png')
					}
				],
				goldInfo: {},
				goldPrice:'0.00',
				_timer: null,
			}
		},
		onShow() {
			this.getMytockFc()
			this.homepage_goldHandle()
		},
		onHide() {
			clearInterval(this._timer)
		},
		onUnload() {
			clearInterval(this._timer)	
		},
		onPageScroll(e) {
			// 判断滚动距离是否超过状态栏高度
			this.isSticky = e.scrollTop > this.statusBarHeight ? true : false
		},
		methods: {
			homepage_goldHandle() {
				if (this._timer) clearInterval(this._timer)
				const uid = uni.getStorageSync('UID') || 0
				this._timer = setInterval(() => {
					homepage_gold({
						uid: uid
					}).then((res) => {
						this.goldPrice = res.data[0].price
					})
				}, 1000)
			},
			getMytockFc() {
				getMytock().then(res => {
					if (res.status != 200) return
					this.goldInfo = res.data
				})
			},
			change(index) {
				if (index == 0) {
					this.$util.JumpPath('/pages/new_gold/goldWarehouse/sell')
				} else if (index == 1) {
					this.$util.JumpPath('/pages/new_gold/goldWarehouse/carryOlder')
				} else {
					uni.setStorageSync('goods_cate_index', 1)
					this.$util.JumpPath('/pages/goods_cate/goods_cate')
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.goldWarehouse {
		position: relative;
		width: 100%;
		height: 100vh;
		background: rgb(246, 235, 213);
		background-size: contain;
		background-repeat: no-repeat;
		padding-bottom: 140rpx;
		overflow: hidden;
	}


	.headBarBox {
		z-index: 1000;
		width: 700rpx;
		height: 103rpx;
		border-radius: 13rpx 13rpx 0 0;
		background: rgba(213, 189, 145, 1);
		margin: -200rpx auto 0;

		.barItem {
			width: 25%;
			font-size: 32rpx;
			font-weight: 500;
			letter-spacing: 0rpx;
			line-height: 46.34rpx;
			color: rgba(255, 255, 255, 1);
			text-align: center;
			vertical-align: top;
		}

		.barItemActive {
			height: 120rpx;
			margin-top: -40rpx;
			background: #fff;
			font-size: 32rpx;
			font-weight: 550;
			letter-spacing: 0rpx;
			line-height: 100rpx;
			color: rgba(61, 61, 61, 1);
			text-align: center;
			border-radius: 40rpx 40rpx 0 0;

		}
	}


	.main_box {
		width: 690rpx;
		margin: 0 auto;
		margin-top: 100rpx;
		background: rgb(245, 236, 215);

		.title_box {
			overflow: hidden;
			width: 100%;
			height: 300rpx;
			margin: 0 auto;
			border-radius: 26rpx 26rpx 0rpx 0rpx;
			background: linear-gradient(90deg, rgba(244, 234, 204, 1) 0%, rgba(246, 239, 222, 1) 52.2%, rgba(237, 223, 189, 1) 100%);

			image {
				width: 100%;
				height: 100%;
			}
		}

		.gold_price {
			width: 323rpx;
			height: 57rpx;
			line-height: 57rpx;
			margin: 0 auto;
			border-radius: 8rpx;
			background: #383838;
			color: #F8ECD9;
			font-size: 28rpx;
			text-align: center;
		}
	}

	.content_box {
		padding-top: 40rpx;
		padding-bottom: 70rpx;
		width: 690rpx;
		border-radius: 13rpx;
		background: rgba(255, 255, 255, 0.1);
		margin: 0rpx auto;
		overflow: hidden;
		border: 2rpx solid #FFFFFF;
		border-top: unset;
		box-shadow: inset 0rpx 2rpx 40rpx #FFFFFF;

		.contentTop {
			display: flex;
			align-items: center;
			justify-content: space-around;
			padding-top: 36rpx;



			.contentTopItem {
				position: relative;
				width: 50%;
				font-size: 28rpx;
				font-weight: 550;
				color: rgba(61, 61, 61, 1);
				text-align: center;

				.redTxt {
					color: #d43030;
					font-size: 48rpx;
					font-weight: 700;
				}
			}

			.contentTopItem:first-of-type::before {
				content: '';
				position: absolute;
				right: 0;
				top: 0;
				width: 2rpx;
				height: 79rpx;
				background: rgba(207, 170, 112, 1);
			}

		}

		.main_class {
			position: relative;
			width: 640rpx;
			height: 483rpx;
			border-radius: 20rpx;
			margin: 24rpx auto 0;
			overflow: hidden;

			background: linear-gradient(90deg, #E1C498 0%, #FAEEDE 46.53%, #F2E3C6 100%);
			border: 2rpx solid #FFFFFF;

			box-shadow: 0rpx 2rpx 20rpx rgba(160, 117, 60, 0.3);

			.my_wight_class {
				width: 377.5rpx;
				text-align: center;
				height: 56rpx;
				line-height: 56rpx;
				color: rgba(244, 234, 205, 1);
				margin: 0 auto 55rpx;
				background-image: url('@/static/statacImg/my_bg.png');
				background-repeat: no-repeat;
				background-size: cover;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.info_box {
				text-align: center;
				font-size: 30rpx;

				line-height: 50rpx;

				.info_title {
					font-weight: bold;
					color: #383838;
				}

				.unitPrice {
					font-size: 34rpx;
					color: #6E4913;


				}

				.estimate {
					font-size: 28rpx;
					color: #9C7233;
				}

				.btn_box {
					width: 538rpx;
					height: 112rpx;
					margin: 50rpx auto 0;
					border-radius: 16rpx;
					background: #FFFFFF;
					text-align: center;
					line-height: 112rpx;
					font-size: 30rpx;
					color: #6E4913;

				}
			}
		}

		.inoutBox {
			padding: 65rpx 24rpx 0;

			.listItem {
				width: 200rpx;
				height: 184rpx;
				font-size: 30rpx;
				letter-spacing: 0rpx;
				line-height: 43.44rpx;
				color: rgba(61, 61, 61, 1);
				text-align: center;
				border-radius: 12rpx;
				background: rgba(213, 189, 145, 0.4);

				image {
					display: block;
					width: 58.87rpx;
					height: 58.88rpx;
					margin: 31rpx auto 18rpx;
				}
			}
		}

	}

	.border_bm {
		border-bottom: 2rpx solid #F8F8FA;
	}
</style>